<?php 

// 导入配置文件 + model类
require './configs/config.php';


function __autoload($classname){

    if (file_exists("./models/{$classname}.class.php")) {
        require './models/Model.class.php';
    } elseif (file_exists("./controllers/{$classname}.class.php")) {
        require "./controllers/{$classname}.class.php";
    } else {
        echo "<script>alert('404 not found!!!!!')</script>";
        echo "<h1>404 not found!!!</h1>";
    }
}


//获取用户的参数
//获取控制器名
$c = (!empty($_GET['c']))?$_GET['c']:'Index';
//获取操作名
$a = (!empty($_GET['a']))?$_GET['a']:'index';

//拼装类名
$classname = $c.'Controller';
//实例化控制器
$controller = new $classname();
// var_dump($controller);
// 调用方法
$controller->$a();